package com.bootx.predict.pojo;

import org.apache.commons.lang3.builder.CompareToBuilder;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;

import java.util.List;
import java.util.Set;

/**
 * @author black
 */
public abstract class PredictPlugin implements Comparable<PredictPlugin> {

    public abstract String getName();

    public abstract List<PredictionResult> predict(List<RedPacketBatch> list, Set<Integer> indexes);


    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        if (this == obj) {
            return true;
        }
        PredictPlugin other = (PredictPlugin) obj;
        return new EqualsBuilder().append(getName(), other.getName()).isEquals();
    }

    @Override
    public int hashCode() {
        return new HashCodeBuilder(17, 37).append(getName()).toHashCode();
    }

    @Override
    public int compareTo(PredictPlugin storagePlugin) {
        return new CompareToBuilder().append(getName(), storagePlugin.getName()).toComparison();
    }
}
